package homework3;

public class MyTime {
    private int hour;
    private int minute;
    private int second;

    public MyTime() {
    }

    public MyTime(int hour, int minute, int second) {
        this.hour = hour;
        this.minute = minute;
        this.second = second;
    }

    public int getHour() {
        return hour;
    }

    public void setHour(int hour) {
        this.hour = hour;
    }

    public int getMinute() {
        return minute;
    }

    public void setMinute(int minute) {
        this.minute = minute;
    }

    public int getSecond() {
        return second;
    }

    public void setSecond(int second) {
        this.second = second;
    }

    public void diaplay(){
        System.out.println(this.hour + "时" + this.minute + "分" + this.second + "秒");
    }

    public void addSecond(int sec){
//        this.setSecond(this.getSecond() + sec);
        int oldSec = this.getSecond();
        int newSec = oldSec + sec;
        if(newSec < 60){
            this.setSecond(newSec);
        }else if(newSec == 60){
            this.addMinute(1);
            this.setSecond(0);
        }else{
            this.addMinute(newSec/60);
            this.setSecond(newSec % 60);
        }
    }
    public void addMinute(int min){
        int oldMinute = this.getMinute();
        int newMinute = oldMinute + min;
        this.setMinute(newMinute);

    }
    public void addHour(int hou){

    }
    public void subSecond(int sec){

    }
    public void subMinute(int min){

    }
    public void subHour(int hou){

    }

}
